package com.tencent.sr.iris.basic.saas.service.model.advisor;

import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.tencent.sr.iris.activity.interfaces.response.group.AdvisorNormalTaskSecondResponse;
import com.tencent.sr.iris.basic.saas.common.utils.CommonUtils;
import com.tencent.sr.iris.user.core.service.interfaces.enums.UserLevelEnum;
import io.swagger.annotations.ApiModel;
import java.util.Map;
import java.util.Optional;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;

@Data
@ApiModel(value = "导师视角二级页面-(普通团推团)导出信息")
@Slf4j
@ColumnWidth(15)
public class AdvisorBoardNormalExportInfo {
    @ExcelProperty(value = "序号", index = 0)
    private int num;

    @ExcelProperty(value = "报名时间", index = 1)
    private String taskPhaseJoinTime;

    @ExcelProperty(value = "uid", index = 2)
    private String irisUid;

    @ExcelProperty(value = "union ID", index = 3)
    private String wechatUserUnionid;

    @ExcelProperty(value = "昵称", index = 4)
    private String wechatUserNickname;

    @ExcelProperty(value = "区域", index = 5)
    private String area;

    @ExcelProperty(value = "等级", index = 6)
    private String irisUidLevel;

    @ExcelProperty(value = "全部下级会员", index = 7)
    private Integer countPromoteWechatUserNum;

    @ExcelProperty(value = "贡献中下级会员", index = 8)
    private Integer countPromoteWechatUserNumContributing;

    @ExcelProperty(value = "当月进度", index = 9)
    private String bonusRuleStage;

    @ExcelProperty(value = "当月销售额", index = 10)
    private Double sumMonthValidGmv;

    @ExcelProperty(value = "累计销售额", index = 11)
    private Double sumValidGmv;

    @ExcelProperty(value = "当月收益", index = 12)
    private Double sumMonthValidCommissionBillCommissionFee;

    @ExcelProperty(value = "累计收益", index = 13)
    private Double sumValidCommissionBillCommissionFee;

    @ExcelProperty(value = "当月预估奖励金", index = 14)
    private Double sumMonthPredictAwardAmount;

    @ExcelProperty(value = "当月实际奖励金", index = 15)
    private Double sumMonthAwardAmount;

    @ExcelProperty(value = "累计派发奖励金", index = 16)
    private Double sumPromoteCommissionFee;

    public void readFromSearchResponseData(AdvisorNormalTaskSecondResponse response, Map<Long, String> orgMap) {
        this.setTaskPhaseJoinTime(response.getTaskPhaseJoinTime());
        this.setIrisUid(response.getIrisUid());
        this.setWechatUserUnionid(response.getWechatUserUnionid());
        this.setWechatUserNickname(response.getWechatUserNickname());
        this.setArea(orgMap.getOrDefault(response.getAreaId(), ""));

        String levelText = Optional.ofNullable(UserLevelEnum.getByValue(response.getIrisUidLevel()))
                .map(UserLevelEnum::getDesc).orElse(StrUtil.EMPTY);
        this.setIrisUidLevel(levelText);
        this.setCountPromoteWechatUserNum(response.getCountPromoteWechatUserNum());
        this.setCountPromoteWechatUserNumContributing(response.getCountPromoteWechatUserNumContributing());
        this.setBonusRuleStage("进行至" + response.getBonusRuleStage() + "阶段");
        this.setSumMonthValidGmv(CommonUtils.longToDouble(response.getSumMonthValidGmv()));
        this.setSumValidGmv(CommonUtils.longToDouble(response.getSumValidGmv()));
        this.setSumMonthPredictAwardAmount(CommonUtils.longToDouble(response.getSumMonthPredictAwardAmount()));
        this.setSumMonthAwardAmount(CommonUtils.longToDouble(response.getSumMonthAwardAmount()));
        this.setSumPromoteCommissionFee(CommonUtils.longToDouble(response.getSumPromoteCommissionFee()));

        this.setSumMonthValidCommissionBillCommissionFee(CommonUtils.longToDouble(response.getSumMonthValidCommissionBillCommissionFee()));
        this.setSumValidCommissionBillCommissionFee(CommonUtils.longToDouble(response.getSumValidCommissionBillCommissionFee()));
    }

}


































